package main.动态规划;

/**
 * @author tmh
 * @date 2024/7/24 23:37
 * @description
 */
public class T121买卖股票的最佳时机 {
    public int maxProfit(int[] prices) {
        int result  =0;
        int minPrice = prices[0];
        for (int price : prices) {
            result=Math.max(result,price-minPrice);
            minPrice=Math.min(price,minPrice);
        }
        return result;
    }
}
